package picoevo.ext.evolution;

import picoevo.core.evolution.InitialisationOperator_Population;
import picoevo.core.representation.Population;
import picoevo.ext.representation.Individual_SimpleIndividual;
import picoevo.ext.representation.Population_SimplePopulation;

/**
 * perform the simplest possible initialisation for a population, i.e. just
 * launch embedded individuals initialisation operators
 */
public class InitialisationOperator_Population_SimplePopulation extends InitialisationOperator_Population {

	// ### Constructors ###

	public InitialisationOperator_Population_SimplePopulation() {
		super();
	}

	public InitialisationOperator_Population_SimplePopulation(String __name) {
		super(__name);
	}

	// ### Methods ###

	@Override
	public void initialise(Population __o) {
		// try
		// {
		Population_SimplePopulation population = (Population_SimplePopulation) __o;
		for (int j = 0; j != population.getTemplate().getIntProperty("InitPopSize"); j++) {
			Individual_SimpleIndividual ind = (new Individual_SimpleIndividual("ind#" + (population.getPopulationSize() + 1), population));
			ind.performInitialisation();
			population.registerIndividual(ind);
		}
		// }
		// catch ( java.lang.ClassCastException e )
		// {
		// Display.error(""+this.getClass().getName()+"::initialise(.) - Class
		// cast exception");
		// }
	}

}
